Xceed DataGrid for WPF v7.3 Documentation
In This Topic
    Defining foreign key descriptions
    In This Topic

    The following example demonstrates how to define foreign key descriptions, which will correctly sort and display values rather than keys.

    XAML
    Copy Code
    <Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
     <Grid.Resources>
        <xcdg:DataGridCollectionViewSource x:Key="cvs_orders"
                                           Source="{Binding Source={x:Static Application.Current}, Path=Products}" >
    
             <xcdg:DataGridCollectionViewSource.ItemProperties>
                <xcdg:DataGridItemProperty Name="CategoryID"
                                           Title="Category">
                   <xcdg:DataGridItemProperty.ForeignKeyDescription>
                      <xcdg:DataTableForeignKeyDescription ItemsSource="{Binding Source={x:Static Application.Current}, Path=Categories}"
                                                           ValuePath="CategoryID"
                                                           DisplayMemberPath="CategoryName" />
                   </xcdg:DataGridItemProperty.ForeignKeyDescription>
                </xcdg:DataGridItemProperty>
    
                <xcdg:DataGridItemProperty Name="SupplierID"
                                           Title="Supplier">
                   <xcdg:DataGridItemProperty.ForeignKeyDescription>
                      <xcdg:DataTableForeignKeyDescription ItemsSource="{Binding Source={x:Static Application.Current}, Path=Suppliers}"
                                                           ValuePath="SupplierID"
                                                           DisplayMemberPath="CompanyName" />
                   </xcdg:DataGridItemProperty.ForeignKeyDescription>
                </xcdg:DataGridItemProperty>
             </xcdg:DataGridCollectionViewSource.ItemProperties>
    
          </xcdg:DataGridCollectionViewSource>
     </Grid.Resources>      
    
     <xcdg:DataGridControl x:Name="OrdersGrid"
                           ItemsSource="{Binding Source={StaticResource cvs_orders}}"
                           AutoCreateForeignKeyConfigurations="True"/>
    </Grid>